package com.dearbinge.data.service.impl.inform;

import com.baomidou.mybatisplus.plugins.Page;
import com.dearbinge.data.api.inform.InformService;
import com.dearbinge.data.dao.inform.InformMapper;
import com.dearbinge.data.pojo.inform.Inform;
import com.dearbinge.utils.PageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("informService")
public class InformServicelmpl implements InformService {

    @Autowired
    private InformMapper informMapper;

    @Override
    public Integer update (Inform inform){
        Integer integer = informMapper.update(inform);
        return integer;
    }

    @Override
    public Integer insert (Inform inform){
        Integer integer = informMapper.insert(inform);
        return integer;
    }

    /**
     * 查询举报列表集
     *
     * @return 举报列表集
     */
    @Override
    public Page getInformList(Integer current, Integer size) {
        current = PageUtils.getDefaultValues(current, 1);
        size = PageUtils.getDefaultValues(size, 10);
        Page<Map> page = new Page<>(current, size);
        List<Map> list = informMapper.getInformList(page);
        page.setTotal(list.size());
        page.setRecords(list);
        return page;
    }


    /**
     * 查询指定用戶的举报列表
     *
     * @param userId 用户id
     * @return 指定用戶的举报列表集
     */
    @Override
    public Page getUserInformList(String userId, Integer current, Integer size) {

        current = PageUtils.getDefaultValues(current, 1);
        size = PageUtils.getDefaultValues(size, 10);
        Page<Map> page = new Page<>(current, size);
        //获取用户加入购物车的店铺
        List<Map> list = informMapper.getUserInformList(userId, page);

        page.setTotal(list.size());
        page.setRecords(list);
        return page;
    }
}
